package com.huike.web.controller.common;

import com.huike.common.core.domain.AjaxResult;
import com.huike.common.utils.MinioUtils;
import com.huike.common.utils.uuid.UUIDUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

@RestController
@RequestMapping("common")
public class CommonController {
    @Autowired
    private MinioUtils minioUtils;
    @PostMapping("/upload")
    public AjaxResult getCode(@RequestBody MultipartFile file) {
        String uuid = UUIDUtils.getUUID();
        String originalFilename = file.getOriginalFilename();
        String type = originalFilename.substring(originalFilename.lastIndexOf("."));
        String fileName = uuid+type;
        minioUtils.uploadToMinio(file,fileName);
        return AjaxResult.success();
    }
}
